﻿<%@ page language="C#" autoeventwireup="true" inherits="_edu_teacher_J1_AddPerformance, App_Web_j1_addperformance.aspx.360d3660" %>

<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
    <script language="javascript" src="../../window/jquery/jquery.min.js" type="text/javascript"></script>
    <script language="javascript" src="../../window/jquery-ui/jquery-ui.min.js" type="text/javascript"></script>
    <script language="javascript" src="../../window/JSON/jquery.json.js" type="text/javascript"></script>
    <script language="javascript" src="../../window/message/jquery.message.js" type="text/javascript"></script>
    <script language="javascript" src="../../window/checked/jquery.checked.js" type="text/javascript"></script>
    <script language="javascript" src="../../window/maxInput/jquery.maxInput.js" type="text/javascript"></script>
    <script language="javascript" src="../../window/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script language="javascript" src="../../window/TableRowFocus/jquery.RowFocus.js" type="text/javascript"></script>
    <script language="javascript" src="../../window/StringBuilder/StringBuilder.js" type="text/javascript"></script>
    <script language="javascript" src="../../window/load/jquery.load.js" type="text/javascript"></script>
    <script language="javascript" src="../../window/form/jquery.form.js" type="text/javascript"></script>

    <link href="../../window/_css/jquery-ui.custom.css" rel="stylesheet" type="text/css">
    <link href="../../window/_css/window.css" rel="stylesheet" type="text/css">
    <link href="../../css/listpage.css" rel="stylesheet" type="text/css">
    <title>学校教师列表</title>

    <script language="javascript" type="text/javascript">
    var params = <%=param.ToString() %>;
    var empty = "";

    var options ={ 
                    dataType:  'json', 
                    success:function(data){
                         unload();
                         if(data.state==1){
                            var sindex = data.value.split(',');
                            var panel = $("#ViewData").children("tbody");
                            for(var index=0;index<sindex.length;index++){
                               panel.children(String.format("tr[index='{0}']",sindex[index])).remove();
                            }
                            message(String.format("共提交{0}条教师业绩信息 未提交{1}条！",sindex.length,submitSum - sindex.length),1);
                            index=0;
                         }else{
                            message(data.value,1);
                         }
                    },
                    error: function() {unload(); message("教师业绩提交失败！",1); return false; } 
            }; 
    $(function(){
       cascade($("#pcSchool"),$("#pcTeacher"),true)
   
       $("#pcTeacher").html(params.teacher).change(function(){
            var pcvalue = this.value;
            $("#ViewData").find("select[role='teacher']").each(function(){
                this.value=pcvalue;
            });
       });
       $("#pcSchoolYear").html(params.schoolyear).change(function(){
                var pcvalue = this.value;
                $("#ViewData").find("select[role='schoolyear']").each(function(){
                    this.value=pcvalue;
                });
       });
       $("#pcTerm").html(params.term).change(function(){
                var pcvalue = this.value;
                $("#ViewData").find("select[role='term']").each(function(){
                    this.value=pcvalue;
                });
       });
       $("#pcSchool").html(params.school).change(function(){
                var pcvalue = this.value;
                $("#ViewData").find("select[role='school']").each(function(){
                    this.value=pcvalue;
                });
       });

       $("#pcSchoolClassify").html(params.schoolclass).change(function(){
                var pcvalue = this.value;
                $("#ViewData").find("select[role='schoolclassify']").each(function(){
                    this.value=pcvalue;
                });
       });
       $("#pcGrade").html(params.grade).change(function(){
                var pcvalue = this.value;
                $("#ViewData").find("select[role='grade']").each(function(){
                    this.value=pcvalue;
                });
       });
       
       $("#pcclass") .keydown(function(event){
                if(event.keyCode=="13") {
                   var pcvalue = this.value;
                    $("#ViewData").find(":text[role='class']").each(function(){
                        this.value=pcvalue;
                    });
                } 
       });
       
       $("#pcStudentNumber").keydown(function(event){
                if(event.keyCode=="13") {
                   var pcvalue = this.value;
                    $("#ViewData").find(":text[role='snumber']").each(function(){
                        this.value=pcvalue;
                    });
                } 
       });
       
        $("#pcavg").keydown(function(event){
        if(event.keyCode=="13") {
           var pcvalue = this.value;
            $("#ViewData").find(":text[role='avg']").each(function(){
                this.value=pcvalue;
            });
        } 
        });

        $("#pcpass").keydown(function(event){
        if(event.keyCode=="13") {
           var pcvalue = this.value;
            $("#ViewData").find(":text[role='pass']").each(function(){
                this.value=pcvalue;
            });
        } 
        });

        $("#pcer").keydown(function(event){
        if(event.keyCode=="13") {
           var pcvalue = this.value;
            $("#ViewData").find(":text[role='er']").each(function(){
                this.value=pcvalue;
            });
        } 
        });
       
       $("#pcSubject").html(params.subject).change(function(){
                var pcvalue = this.value;
                $("#ViewData").find("select[role='subject']").each(function(){
                    this.value=pcvalue;
                });
       });
       $("#pcExamType").html(params.examtype).change(function(){
                var pcvalue = this.value;
                $("#ViewData").find("select[role='examtype']").each(function(){
                    this.value=pcvalue;
                });
       });
       
       createNewRow();
       $("#btnAdd").click(function(){
            addRows();
       });
       $("#btnDelete").click(function(){
            $("#ViewData").find(":checked").each(function(){
                $(this).parent().parent().remove(); 
            });
       });
       
       $("#chk_all").checkedAll("ViewData",1);
       $("#chk_Rev").checkedRev("ViewData",1);
       $("#ViewData").RowFocus();
       
       
       $("#btnSubmit").click(function(){
            var right = true;
            $("#ViewData").find(":text[role='snumber']").each(function(){
               if(!this.value.match(/^[0-9]+?$/))
               {
                    this.className='error';right = false;
                    return false;
               }else{
                    this.className=empty;
               }
            
            });
            $("#ViewData").find(":text[role='avg']").each(function(){
               if(!this.value.match(/^[0-9]+(.[0-9]{1,2})?$/))
               {
                    this.className='error';right = false;
                    return false;
               }else{
                    this.className=empty;
               }
            });
            $("#ViewData").find(":text[role='pass']").each(function(){
               if(!this.value.match(/^[0-9]+(.[0-9]{1,2})?$/))
               {
                    this.className='error';right = false;
                    return false;
               }else{
                    this.className=empty;
               }
            });
            $("#ViewData").find(":text[role='er']").each(function(){
               if(!this.value.match(/^[0-9]+(.[0-9]{1,2})?$/))
               {
                    this.className='error';right = false;return false;
               }else{
                    this.className=empty;
               }
            });
            $("#ViewData").find(":text[role='class']").each(function(){
                if(this.value==empty){
                    this.className='error';right = false;return false;
                }else
                {
                    this.className=empty;
                }
            });
            
            $("#ViewData").find("select[role='teacher']").each(function(){
                if(this.value==empty){
                    this.className='error';right = false;return false;
                }else
                {
                    this.className=empty;
                }
            });
            $("#ViewData").find("select[role='grade']").each(function(){
                if(this.value==empty){
                    this.className='error';right = false;return false;
                }else
                {
                    this.className=empty;
                }
            });
            
            $("#ViewData").find("select[role='schoolyear']").each(function(){
                if(this.value==empty){
                    this.className='error';right = false;return false;
                }else
                {
                    this.className=empty;
                }
            });
            
            $("#ViewData").find("select[role='term']").each(function(){
                if(this.value==empty){
                    this.className='error';right = false;return false;
                }else
                {
                    this.className=empty;
                }
            });
            
            $("#ViewData").find("select[role='school']").each(function(){
                if(this.value==empty){
                    this.className='error';right = false;return false;
                }else
                {
                    this.className=empty;
                }
            });
            
            $("#ViewData").find("select[role='schoolclassify']").each(function(){
                if(this.value==empty){
                    this.className='error';right = false;return false;
                }else
                {
                    this.className=empty;
                }
            });
            
            $("#ViewData").find("select[role='subject']").each(function(){
                if(this.value==empty){
                    this.className='error';right = false;return false;
                }else
                {
                    this.className=empty;
                }
            });
            
            $("#ViewData").find("select[role='examtype']").each(function(){
                if(this.value==empty){
                    this.className='error';right = false;return false;
                }else
                {
                    this.className=empty;
                }
            });
            if(right){
                var rowindexs = new Array();
                $("#ViewData").children("tbody").children("tr[role='rinfo']").each(function(){
                     rowindexs.push($(this).attr("index"));
                     
                });
                submitSum = rowindexs.length;
                $("#hfRowIndex").val(rowindexs.join(','));
                
                load("业绩提交中...");
               $("#performance").ajaxSubmit(options);
            }
       }); 
        
           
    });
    var submitSum = 0;
    var index=0;
    function createNewRow(){
        var panel = $("#ViewData").children("tbody");
        var sb = new StringBuilder();
        sb.append(String.format("<tr index='{0}' class='gvRow' role='rinfo'>",index));
             sb.append("<td>");
             sb.append((index+1));
             sb.append("</td>");
             sb.append("<td>");
                sb.append("<input type='checkbox'></td>");
             sb.append("<td>");
                  sb.append(String.format("<select id='school_{0}' name='school_{0}' role='school' >",index));
                  sb.append(params.school);
                  sb.append("</select>");
             sb.append("</td>");
             sb.append("<td>");
                  sb.append(String.format("<select id=\"teacher_{0}\" role='teacher' name='teacher_{0}' style=\"width: 109px\" >",index));
                  sb.append(params.teacher);
                  sb.append("</select>");
             sb.append("</td>");
             sb.append("<td>"); 
                  sb.append(String.format("<select id='schoolyear_{0}' role='schoolyear' name='schoolyear_{0}' style='width: 135px'>",index));
                  sb.append(params.schoolyear);
                  sb.append("</select>");
             sb.append("</td>");
             sb.append("<td>");
                  sb.append(String.format("<select id='term_{0}' name='term_{0}' role='term' style='width: 67px'>",index));
                  sb.append(params.term);
                  sb.append("</select>");
             sb.append("</td>");
   
             sb.append("<td>");
                 sb.append(String.format("<select id='schoolclassify_{0}' name='schoolclassify_{0}' style='width: 50px' role='schoolclassify' >",index)); 
                 sb.append(params.schoolclass);
                 sb.append("</select>");
             sb.append("</td>");
             sb.append("<td>");
                 sb.append(String.format("<select id='grade_{0}' role='grade' role='subject' name='grade_{0}' style='width: 113px'>",index));
                 sb.append(params.grade);
                 sb.append("</select>");
             sb.append("</td>");
             sb.append("<td>");
                 sb.append(String.format("<input id='class_{0}' name='class_{0}' role='class' maxlength='20'  type='text' style='width: 71px' />",index));
             sb.append("</td>");
             sb.append("<td >");
             sb.append(String.format("<input id='snumber_{0}' name='snumber_{0}' role='snumber'  type='text' maxlength='5' style='width: 53px' />",index));
             sb.append("</td>");
             sb.append("<td>");
                 sb.append(String.format("<select id='subject_{0}' name='subject_{0}' role='subject' style='width: 113px' >",index));
                 sb.append(params.subject);
                 sb.append("</select>")
             sb.append("</td>");
             sb.append("<td>");
             sb.append(String.format("<input id='avg_{0}' name='avg_{0}' maxlength='5' role='avg' type='text' style='width: 30px' />",index));
             sb.append("</td>");
             sb.append("<td>");
             sb.append(String.format("<input id='pass_{0}' name='pass_{0}' maxlength='5' role='pass' type='text' style='width: 30px' />%",index));
             sb.append("</td>");
             sb.append("<td>");
             sb.append(String.format("<input id='er_{0}' name='er_{0}' maxlength='5' role='er' type='text' style='width: 30px' />%",index));
             sb.append("</td>");
             sb.append("<td>");
                sb.append(String.format("<select id='examtype_{0}' name='examtype_{0}' role='examtype' style='width: 96px'>",index));
                sb.append(params.examtype);
                sb.append("</select>");
             sb.append("</td>");
             sb.append("</tr>");
             panel.append(sb.tostring());
             cascade(
             $(String.format("#school_{0}",index)),
             $(String.format("#teacher_{0}",index))
             )
             index++;
             
    }
    function validSelect(){
        var trs = $("#ViewData").find(":checked");

        if(trs.size()==0){
            message("请选择操作的数据项！",1);
            return false;
        }
        return true;
    }
    function addRows(){
        var rows = parseInt($("#txtAddNumber").val());
        var sumrows = ($("#ViewData").children("tbody").children("tr").size()-2)+rows;
        if(sumrows>60){
            message("最多可创建60行",1);return;
        }
        for(var i=0;i<rows;i++)
        {
            createNewRow();
        }
        $("#ViewData").RowFocus();
        
        
        $("#sumRow").text(sumrows);
    }
    function cascade(parent,target,ispc){
             //入学年份联动 班级
             parent.change(function(){
                 if(this.value=="")return null;
                 $.ajax({
                       type: "POST",
                       dataType:"json",
                       url:"../../Handler/CascadeSchool_handler.ashx",
                       data: {cascadeSchool:this.value},
                       success: function(data){
                            if(data.state==1){
                                target.html(data.value);
                                if (ispc){
                                    $("#ViewData").find("select[role='teacher']").html(data.value);
                                }
                            }else{
                                message(data.value,1);
                            }
                       },
                       beforeSend:function(){
                            target.html("<option >加载中...</option>");
                            return true;
                       },
                       error: function() {target.html("<option >加载失败...</option>"); return false; } 
                 });
             });
    }
    
    </script>

    <style type="text/css">
<!--
.center {
	text-align: center;
}
.error{
  
    background-color:#ffdab9;
}
-->
</style>
</head>
<body>
        <div class="ui-widget-header " style="padding: .4em 1em; margin:2px">
            <span class="ui-dialog-title" > <%=labTitle%></span>
         
        </div>
        
        <div class="panel">
            共创建<span id="sumRow">1</span> 行| &nbsp;新增：<input id="txtAddNumber" maxlength="2" style="width: 43px" type="text" />
            <input id="btnAdd" class="addnew" type="button" value="添加录入行" >&nbsp;&nbsp; &nbsp;&nbsp;
            <input id="btnDelete" class="delete" name="btnDelete" onclick="if(confirm('确认删除？')){return validSelect(); }else{return false;};"
                type="submit" value="删除选中行" />
            <input id="chk_all" name="chk_all" type="checkbox">全选 <a id="chk_Rev" href="javascript:void(0)">
                反 选</a> <font color="green">*填写后请务必进行检查</font>
        </div>

        <form id="performance" method="post" action="J1_AddPerformance.aspx" >
            <table class="gv"  border="1" id="ViewData" style="background-color: White; width:100%;
                 border-collapse: collapse;">
                <tbody>
                    <tr class="gvHeader">
                        <th>
                            序号
                        </th>
                        <th>
                            选择</th>
                        <th style="width: 111px">
                            任教学校</th>
                        <th style="width: 111px" >
                            教师姓名</th>
                        <th style="width: 138px">
                            年度</th>
                        <th style="width: 72px">
                            学期</th>
                        <th>
                            学校分类</th>
                        <th style="width: 113px">
                            年级</th>
                        <th>
                            班级</th>
                        <th >
                            学生数</th>
                        <th style="width: 119px">
                            任教学科</th>
                        <th>
                            平均分</th>
                        <th>
                            及格率</th>
                        <th>
                            优生率</th>
                        <th style="width: 100px">
                            考试类别</th>
                    </tr>
                    <tr class='gvRow'>
                        <td>
                         </td>
                        <td>
                        </td>
                        <td>
                            <select id="pcSchool" style="width: 111px">  
                            </select>
                        </td>
                        <td >
                            <select id="pcTeacher" style="width: 109px" > 
                            </select>
                        </td>
                        <td>
                            <select id="pcSchoolYear" style="width: 135px" >
                            </select>
                        </td>
                        <td>
                            <select id="pcTerm" style="width: 67px" >
                            </select>
                        </td>
                 
                        <td> 
                            <select id="pcSchoolClassify" style="width: 50px">  
                            </select>
                         </td>
                        <td>
                            <select id="pcGrade" style="width: 113px" >
                            </select>
                        </td>
                        <td>
                            <input id="pcclass"  type="text" style="width: 71px" maxlength="20" />
                        </td>
                        <td >
                        <input id="pcStudentNumber"  type="text" style="width: 53px" maxlength="5" />
                        </td>
                        <td><select id="pcSubject" style="width: 113px" ></select>
                        </td>
                        <td><input id="pcavg"  type="text" style="width: 30px" maxlength="5" />&nbsp;
                        </td>
                        <td> 
                         <input id="pcpass"  type="text" style="width: 30px" maxlength="5" />%
                        </td>
                        <td>
                         <input id="pcer"  type="text" style="width: 30px" maxlength="5" />%
                        </td>
                        <td >
                            <select id="pcExamType" style="width: 96px">
                            </select>
                        </td>
                    </tr>
      
                </tbody>
            </table>
            <div class="title"  align="center" ><input id="btnSubmit" type="button" value="提交教师教学业绩" /></div>
            <input id="hfRowIndex" name='rowindex' type="hidden" />
    </form>    
</body>
</html>
